from flask import Flask, request, jsonify
import random

app = Flask(__name__)

@app.route('/get_price', methods=['POST'])
def get_price():
    auth_header = request.headers.get('Authorization')
    if auth_header != 'Bearer dengyao7':
        return {"msg": "Invalid Authorization header"}, 403
    short_video_platform = request.json.get('short_video_platform', None)
    daren_level = request.json.get('daren_level', None)
    business = request.json.get('business', None)

    # 打印变量
    print(f"short_video_platform: {short_video_platform}")
    print(f"daren_level: {daren_level}")
    print(f"business: {business}")

    if daren_level is None:
        return jsonify({
            'status': 'error',
            'errorInfo': 'No price provided',
            'data': None
        })

    if short_video_platform == "抖音":
        if business == "云剪":
            price = "100-300"
        if business =="实探":
            price = "300-500"
    else:
        price = "50"

    # 返回对LLM友好的字符串格式的响应
    print(f"目前{short_video_platform}的{business}需要达人等级{daren_level}费用在{price}")
    return f"目前{short_video_platform}的{business}需要达人等级{daren_level}费用在{price}"

if __name__ == '__main__':
    app.run(host='0.0.0.0',debug=False, port=16801)

